package one.stand.controller;

import com.jmp.autocofiguration.web.interceptor.SecurityAuthCheck;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import one.stand.model.ResultModel;
import one.stand.request.FinanceRequest;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 公司财务/销售
 *
 * @author Administrator
 */
@RequestMapping("/finance")
@RestController
public class FinanceController extends BaseController {

    @ApiOperation(value = "公司财务统计-总收入")
    @PostMapping("/getGrossIncome")
    @SecurityAuthCheck(company = true, card = true)
    public ResultModel getGrossIncome(@RequestAttribute FinanceRequest request) {

        return crmFegin.getGrossIncome(request);
    }

    @ApiOperation(value = "公司财务统计-商城流水")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "whereDate", value = "日期（年月）", paramType = "Integer"),
    })
    @PostMapping("/selectFinanceMall")
    @SecurityAuthCheck(company = true, card = true)
    public ResultModel<Map<String, Object>> selectFinanceMall(@RequestAttribute FinanceRequest request) {

        return crmFegin.selectFinanceMall(request);
    }

    @ApiOperation(value = "公司财务统计-成交流水")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "whereDate", value = "日期（年月）", paramType = "Integer"),
    })
    @PostMapping("/selectFinanceDeal")
    @SecurityAuthCheck(company = true, card = true)
    public ResultModel<Map<String, Object>> selectFinanceDeal(@RequestAttribute FinanceRequest request) {

        return crmFegin.selectFinanceDeal(request);
    }

    @ApiOperation(value = "公司财务统计-公司流水")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "whereDate", value = "日期（年月）", paramType = "Integer"),
    })
    @PostMapping("/selectFinanceCompany")
    @SecurityAuthCheck(company = true, card = true)
    public ResultModel<Map<String, Object>> selectFinanceCompany(@RequestAttribute FinanceRequest request) {

        return crmFegin.selectFinanceCompany(request);
    }

    @ApiOperation(value = "公司销售排行-客户人数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "whereDate", value = "不传值是查客户总数，1新增客户", paramType = "Integer"),
    })
    @PostMapping("/selectCustomerNum")
    @SecurityAuthCheck(company = true, card = true)
    public ResultModel<Map<String, Object>> selectCustomerNum(@RequestAttribute FinanceRequest request) {

        return crmFegin.selectCustomerNum(request);
    }

    @ApiOperation(value = "公司销售排行-订单量")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "1订单总数，2成交金额，3月目标", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "days", value = "7天，15天，30天传对应数字", paramType = "Integer"),
    })
    @PostMapping("/selectOrderNum")
    @SecurityAuthCheck(company = true, card = true)
    public ResultModel<Map<String, Object>> selectOrderNum(@RequestAttribute FinanceRequest request) {

        return crmFegin.selectOrderNum(request);
    }

    @ApiOperation(value = "公司销售排行-互动频率")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "1跟进总数 2咨询总数", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "days", value = "7天，15天，30天传对应数字", paramType = "Integer"),
    })
    @PostMapping("/selectInteractionNum")
    @SecurityAuthCheck(company = true, card = true)
    public ResultModel<Map<String, Object>> selectInteractionNum(@RequestAttribute FinanceRequest request) {

        return crmFegin.selectInteractionNum(request);
    }

    @ApiOperation(value = "公司销售排行-成交率区间")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "days", value = "7天，15天，30天传对应数字", paramType = "Integer"),
    })
    @PostMapping("/selectDelNum")
    @SecurityAuthCheck(company = true, card = true)
    public ResultModel<Map<String, Object>> selectDelNum(@RequestAttribute FinanceRequest request) {
        return crmFegin.selectDelNum(request);
    }

}
